#! /usr/bin/python


def post0(arg1, arg2):
    pass


def get0(arg1):
    pass


post = None
get = None

try:
    import requests
except:
    post = post0
    get = get0
else:
    post = requests.post
    get = requests.get
execfile("../cfg/at/other.cfg")

baseUrl = 'http://127.0.0.1:' + str(server_port) + '/'


def at(msg):
    url = baseUrl + 'at'
    d = {'msg': msg}
    try:
        post(url, data=d)
    except:
        pass
    finally:
        return


def add(key, val):
    l = key.split('_')
    url = baseUrl + 'test/' + '/'.join(l) + '?count=' + str(val)
    try:
        get(url)
    except:
        pass
    finally:
        return


def req(path):
    url = baseUrl + path
    try:
        get(url)
    except:
        pass
    finally:
        return
